<template>
  <!-- 热门推荐列组件 -->
  <ul class="musicBox">
    <router-link
      :to="{ name: 'songsheetdetail', query: { id: item.id } }"
      tag="li"
      v-for="(item, index) in PopularRecommendationList"
      :key="index"
      class="musicItem"
    >
      <div class="imgBox">
        <img class="musicImg" :src="item.picUrl" alt="" />
        <div class="musicplayNumBox">
          <div class="headset"></div>
          <span class="palyNumBox"
            >{{ parseInt(item.playCount / 10000) }}万</span
          >
          <div class="playBtn" @click.stop="PlayClick(item.id)"></div>
        </div>
      </div>
      <p class="itemName">{{ item.name }}</p>
    </router-link>
  </ul>
</template>

<script>
import { songSheetDetail } from "@/api";
import { mapState, mapActions } from "vuex";
export default {
  data: function () {
    return {};
  },
  props: {
    PopularRecommendationList: { type: Array, default: [] },
  },
  methods: {
    ...mapActions("musicStore", ["songSheetPlay"]),
    PlayClick(id) {
      //直接点击播放
      songSheetDetail({ id }).then((res) => {
        this.songSheetPlay(res.playlist.tracks);
      });
    },
  },
};
</script>

<style lang="scss" scoped>
// .musicClassification {
//   height: 33px;
//   padding: 0 10px 0 34px;
//   background-position: -225px -156px;
//   border-bottom: 2px solid #c10d0c;
//   display: flex;
//   background-image: url("./../../assets/imges/PopularRecommendationIcon.png");
//   background-repeat: no-repeat;
// }
// .ValBox {
//   padding: 20px 20px 40px;
// }
// .titOne {
//   font-size: 20px;
//   font-weight: normal;
//   line-height: 28px;
// }
// .classificationBox {
//   flex: 1;
//   color: #666;
//   font-size: 12px;
//   margin: 7px 0 0 20px;
// }
// .classificationBox span {
//   margin: 0 6px;
// }
// .moreBox {
//   color: #666;
//   font-size: 12px;
//   margin-top: 7px;
//   background-image: url("./../../assets/imges/PopularRecommendationIcon.png");
//   background-repeat: no-repeat;
//   background-position: 28px -237px;
//   padding-right: 18px;
// }
.imgBox {
  width: 140px;
  height: 140px;
  position: relative;
}
.musicImg {
  width: 100%;
  height: 100%;
}
.musicplayNumBox {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  font-size: 12px;
  height: 27px;
  background-position: 0 -537px;
  color: #ccc;
  background-image: url("./../../assets/imges/background.png");
  display: flex;
  align-items: center;
}
.headset {
  width: 14px;
  height: 11px;
  vertical-align: middle;
  background-position: 0 -24px;
  margin: 9px 5px 9px 10px;
  display: inline-block;
  background-image: url("./../../assets/imges/btnIcon.png");
}
.playBtn {
  width: 16px;
  background-image: url("./../../assets/imges/btnIcon.png");
  height: 17px;
  display: inline-block;
  padding-right: 10px;
}
.palyNumBox {
  flex: 1;
}
.musicItem {
  width: 140px;
  font-size: 14px;
  height: 204px;
}
.musicBox {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  margin-top: 20px;
}
.itemName {
  margin: 8px 0 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
</style>